#!/usr/bin/env python3
# -*- coding: utf-8 -*-

'使用@closing实现某对象的上下文'

from contextlib import closing
from urllib.request import urlopen

with closing(urlopen('http://www.python.org')) as page:
    for line in page:
        print(line)
